import { PersistGate } from "redux-persist/integration/react";
import {
  CraeteCollection,
  CollectionProvider
} from "@/hooks/useCollection/index";
import { getWhiteScreen } from "@/hooks/useCollection/getwhiteScreen";
import { defaultModeType } from "@/hooks/useCollection/type";
import ReactDOM from "react-dom/client";
import { ConfigProvider, App as AntdApp } from "antd";
import { Provider } from "react-redux";
import { store, persistor } from "./store/index";
import zhCN from "antd/locale/zh_CN";
import App from "./App";
import "virtual:svg-icons-register";
import "./index.css";
window.addEventListener("load", () => {
  window.LOAD_DONE = true;
  if (window.parent != window) {
    window.parent.postMessage(
      JSON.stringify({
        type: "loadDone",
        data: true
      })
    );
  }
});

CraeteCollection({
  collectPageStay: true,
  defaultMode: defaultModeType.Img,
  proxyUrl: "http://localhost:3000/info"
});

getWhiteScreen();

ReactDOM.createRoot(document.getElementById("root")!).render(
  <ConfigProvider
    locale={zhCN}
    theme={{
      components: {
        Drawer: {
          footerPaddingInline: 4,
          footerPaddingBlock: 2
        }
      }
    }}
  >
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
        <CollectionProvider>
          <AntdApp>
            <App></App>
          </AntdApp>
        </CollectionProvider>
      </PersistGate>
    </Provider>
  </ConfigProvider>
);
